module Utils
  module Text
    protected
      def capitalize_each_word(str)
        str.split(' ').collect{|part| part.capitalize << " "}.to_s.strip
      end

      def shorten(value,length)
        return if value.nil?
        return value if value.length < length
        value.to_s[0..(length-3)] + "..."
      end

      def add_text?(txt, tru)
        return txt if txt and tru
        return ""
      end
      
      def empty_or_nil?(v)
        return true if v.nil?
        return true if v.to_s.strip.length == 0
        return false
      end

      def mmddyyyy(time)
        time.strftime("%m/%d/%Y")
      end

      def day_month_year(time)
        time.strftime("%d %b, %Y")
      end
  end
end
